import request from '../utils/request'

export interface WorkflowForm {
  id?: number
  workflowName: string
  workflowCode: string
  status: 0 | 1
  systemId: number
}

// 获取流程列表
export function getProcessList(systemId: string | number) {
  return request({
    url: `/api/process/list/${systemId}`,
    method: 'get'
  })
}

// 删除流程
export function deleteProcess(id: number) {
  return request({
    url: `/api/process/delete/${id}`,
    method: 'delete'
  })
}

// 保存工作流
export function saveWorkflow(data: FormData) {
  return request({
    url: '/api/process/deploy',
    method: 'post',
    data
  })
}

// 删除流程
export const deleteWorkflow = (id: number) => {
  return request({
    url: `/api/process/${id}`,
    method: 'delete'
  })
}

// 获取流程XML
export function getProcessXML(id: number) {
  return request({
    url: `/api/process/xml/${id}`,
    method: 'get'
  })
} 

export function updateWorkflow(id: number, data: FormData) {
  return request({
    url: `/api/process/update/${id}`,
    method: 'post',
    data
  })
}